{% load i18n %}
function listCommitDetails(url, t) {
    $.modal('<div id="ls-ch"><img src="{{MEDIA_URL}}img/loading-icon.gif" alt="" style="margin-top:30px;" /></div>', {autoResize:true});
    $('#ls-ch').css('text-align', 'center');
    $('#simplemodal-container').css({'width':'auto', 'height':'auto'});
    $.ajax({
        url: url,
        dataType: 'json',
        cache: false,
        success: function(data) {
            var heading = '<h3>' + "{% trans "Modification Details" %}" + '</h3>';
            var time = '<p class="commit-time">' + t + '</p>';
            var con = '';
            function show(data_, hd) {
                if (data_.length > 0) {
                    con += '<h4>' + hd + '</h4>';
                    con += '<ul>';
                    for (var i = 0, len = data_.length; i < len; i++) {
                        con += '<li>' + data_[i] + '</li>';
                    }
                    con += '</ul>';
                }
            }
            show(data['new'], "{% trans "New files" %}");
            show(data['removed'], "{% trans "Deleted files" %}");
            show(data['renamed'], "{% trans "Renamed or Moved files" %}");
            show(data['modified'], "{% trans "Modified files" %}");
            show(data['newdir'], "{% trans "New directories" %}");
            show(data['deldir'], "{% trans "Deleted directories" %}");
            if (!con) {
                if (data['cmt_desc']) {
                    con = '<p>' + HTMLescape(data['cmt_desc']) + '</p>';
                }
            }
            $('#ls-ch').css('text-align','left').html(heading + time + con);
            $(window).resize();
        },
        error: function() {
            $('#ls-ch').html("{% trans "Unknown error." %}");
            setTimeout(function() { $.modal.close(); }, 2500);
        }
    });
}
$('.lsch').click(function() {
    listCommitDetails($(this).data('url'), $(this).data('time'));
    return false;
});
